module(name = "basic_gazelle")

# This example depends on the Bazel modules rules_go and gazelle.
# Bazel modules are different than Go modules: Bazel modules are
# published on registry.bazel.build and have their own build files.
bazel_dep(name = "rules_go", version = "0.52.0")
bazel_dep(name = "gazelle", version = "0.42.0")

# Configure rules_go to download and build with a specific version of Go.
#
# use_extension here loads the go_sdk Bazel module extension.
# A module extension is a bit of code that tells Bazel how to fetch things
# that aren't normal modules.
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.23.4")

# Configure Gazelle to load the list of Go modules from go.mod using the
# go_deps module extension.
#
# go_deps fetches Go modules using 'go mod download'. It then generates
# build files for them using Gazelle.
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")

# Import repos generated by the go_deps module extension into this module.
#
# A Bazel repo is a separate source tree, either provided by a Bazel module
# (bazel_dep) or a module extension. go_deps creates a repo for each Go module.
# We must declare the modules we use directory from this repository, but the
# list does not need to be maintained manually: you can run 'bazel mod tidy' to
# update it automatically.
#
# Bazel repo names allow a limited set of characters, so Go module
# paths need to be transformed. Domains like golang.org are reversed, and
# characters other than letters and numbers are replaced with underscores (_).
# So "golang.org/x/net" becomes "org_golang_x_net".
#
# You can refer to targets within these repos with a label like
# "@org_golang_x_net//html".
use_repo(
    go_deps,
    "com_github_stretchr_testify",
    "org_golang_x_net",
)
